package com.xinxing.city.recovery.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xinxing.city.recovery.R;
import com.xinxing.city.recovery.databinding.ActivityOpsSet5Binding;
import com.xinxing.city.recovery.entitys.SetCategory;
import com.xinxing.city.recovery.entitys.SetReceive;
import com.xinxing.city.recovery.utils.SharedPreferencesUtils;

import java.lang.reflect.Type;

public class OpsSet5Activity extends AppCompatActivity {
    private ActivityOpsSet5Binding binding;
    private SetReceive setReceive = new SetReceive();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,R.layout.activity_ops_set5);
        setReceive.setTopTitle("正在结算中，请稍等");
        init();
        binding.setSetReceive(setReceive);
    }
    private void init(){
        String str = (String) SharedPreferencesUtils.getParam(this,"ops_settlement","");
        if(!str.equals("")){
            Type dev = new TypeToken<SetReceive>() {}.getType();
            Gson gson = new Gson();;
            setReceive = gson.fromJson(str,dev);
        }
    }
    public void saveSub(View view) {
        Gson gson = new Gson();
        SharedPreferencesUtils.setParam(this, "ops_settlement", gson.toJson(setReceive));
        Toast.makeText(this, "保存成功", Toast.LENGTH_SHORT).show();
        OpsSet5Activity.this.finish();
    }
}